﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Drawing;

namespace Weebing.Web
{
    public partial class Default : System.Web.UI.Page
    {
        public void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                dynImg.ImageId = Guid.NewGuid().ToString().Replace("-", "_");
                Session["imgText"] = dynImg.ImageId.Substring(0, 6);
            }   
        }

        public void dynImg_RetrieveImage(object sender, Gaia.WebWidgets.DynamicImage.RetrieveImageEventArgs e)
        {
            e.Image = new Bitmap(100, 50);
            Graphics g = Graphics.FromImage(e.Image);

            // Background color   
            g.FillRectangle(
                new SolidBrush(Color.Salmon),
                0,
                0,
                e.Image.Width,
                e.Image.Height);

            // Text   
            string imgText = Session["imgText"] as string;
            g.DrawString(imgText, new Font(FontFamily.GenericSansSerif, 12F, FontStyle.Bold), new SolidBrush(Color.Black), 10, 12);
        }

        protected void buttonRegister_Click(object sender, EventArgs e)
        {
            labelTitle.Text = "Fill out to register!";

            panelContent.Visible = false;
            panelRegister.Visible = true;
        }

        protected void btnRegister_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                labelTitle.Text = "You are Connected!";

                panelRegister.Visible = false;
                panelWelcome.Visible = true;
            }
            else
            {
                labelTitle.Text = "Whops! Something went wrong!";
            }
        }

        public void linkWorks_Click(object sender, EventArgs e)
        {
            panelContent.Visible = false;
            panelRegister.Visible = false;
            panelWelcome.Visible = false;

            panelWorks.Visible = true;
        }
    }
}
